package com.han.spring.mvc._0143_Handler_Methods;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttribute;
import org.springframework.web.bind.annotation.SessionAttributes;

/**
* @author hanpeng
* @version 创建时间：2020年8月2日 下午10:26:25
* @ClassName 类名称
* @Description 类描述
*/
/*@SessionAttributes(names= {"user"})*/
@Controller
public class ModelAttributeController {
	private  static Log log = LogFactory.getLog(SessionAttributesController.class);
	private  static final String SUCCESS="success";
	
	@ModelAttribute(binding=false)
	public void modelAtt(Model model) {
		System.out.println("modelAtt");
		model.addAttribute("user", new User("fdasd", 11));
	}
/*	@ModelAttribute
	public void modelAtt1(Model model) {
		System.out.println("modelAtt1");
		// key必须和后面的入参相同才能取得值
		model.addAttribute("user1", new User("fdas11d", 11111));
	}*/
	@RequestMapping("/modelAttribute")
	public String modelAttribute(User user,User user1) {
		System.out.println(user1);
		System.out.println(user);
		return SUCCESS;
	}
}
